package service

import (
	"context"
	"webook/internal/domain"
	"webook/internal/repository"
)

//go:generate mockgen -source=./interactive.go -package=svcmocks -destination=mock/interactive.mock.go
type IInterActiveService interface {
	IncrReadCnt(ctx context.Context, biz string, bizId int64) error
	Like(ctx context.Context, biz string, articleId int64, userId int64) error
	CancelLike(ctx context.Context, biz string, articleId int64, userId int64) error
	ListByBizIds(ctx context.Context, biz string, bizIds []int64) (map[int64]domain.Interactive, error)
}

type InterActiveService struct {
	repo repository.InterActiveRepository
}

func (i *InterActiveService) ListByBizIds(ctx context.Context, biz string, bizIds []int64) (map[int64]domain.Interactive, error) {
	//TODO implement me
	panic("implement me")
}

func NewInterActiveService(repo repository.InterActiveRepository) IInterActiveService {
	return &InterActiveService{
		repo: repo,
	}
}

func (i *InterActiveService) Like(ctx context.Context, biz string, articleId int64, userId int64) error {
	return i.repo.IncrLike(ctx, biz, articleId, userId)
}

func (i *InterActiveService) CancelLike(ctx context.Context, biz string, articleId int64, userId int64) error {
	return i.repo.DecrLike(ctx, biz, articleId, userId)
}

func (i *InterActiveService) IncrReadCnt(ctx context.Context, biz string, bizId int64) error {
	return i.repo.IncrReadCnt(ctx, biz, bizId)
}
